package org.hbhk.aili.job.event;

import java.util.Map;

import org.hbhk.aili.job.configuration.CommonJob;
import org.hbhk.aili.job.configuration.HttpElasticScheduler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.google.common.collect.Maps;

public class HttpCommonJob extends CommonJob {

	Logger log = LoggerFactory.getLogger(HttpCommonJob.class);

	@Override
	public void doExecute(ShardingContext shardingContext) {
		String jobName = shardingContext.getJobName();
		log.info(jobName + "http开始执行");
		HttpJobConfig jobConfig = HttpElasticScheduler.httpJobCache.get(jobName);
		if (jobConfig == null) {
			log.info("http调用服务不存在:" + jobName);
			return;
		}
		String url = jobConfig.getAddress();
		Map<String, String> headers = Maps.newHashMap();
		headers.put("User-Agent",
				"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36");
		HttpClientUtil.browserPost(url, headers, "{}", null);
		log.info(jobName + "http结束执行:" + url);

	}

}
